package com.haoshuang.zhouzhoubang.ui.adapter

import android.graphics.Color
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemBalanceDetailBinding
import com.haoshuang.zhouzhoubang.model.bean.BalanceDetailGroupListBean
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.textColor
import com.noober.background.drawable.DrawableCreator

/**
 *
 */
class BalanceDetailAdapter(data: MutableList<BalanceDetailGroupListBean.BalanceDetailGroupBean.BalanceDetailBean>) :
    BaseBindingQuickAdapter<BalanceDetailGroupListBean.BalanceDetailGroupBean.BalanceDetailBean, ItemBalanceDetailBinding>(
        data
    ) {

    override fun onBindViewHolder(
        holder: BaseBindingHolder,
        position: Int,
        item: BalanceDetailGroupListBean.BalanceDetailGroupBean.BalanceDetailBean?
    ) {
        holder.getViewBinding<ItemBalanceDetailBinding>().apply {

            tvTitle.text = item?.mark
            tvTime.text = item?.add_time
            if (item?.pm == 1) {
                tvValue.textColor = R.color.c_00c24e
                tvValue.text = "${item.number}"
            } else {
                tvValue.textColor = R.color.c_ff0000
                tvValue.text = item?.number
            }

            val b = DrawableCreator.Builder()
            b.setShape(DrawableCreator.Shape.Oval)
            /*






        pay_product：商城






             */
            when(item?.type){
                "reward_money","upload_video_award","system_add","spread_service" -> {
                    b.setSolidColor(Color.parseColor("#66F65E2A"))
                    tvBillType.text = "奖励"
                }
                "team_service_work" ,"team_service_work_heixao"-> {
                    b.setSolidColor(Color.parseColor("#66F65E2A"))
                    tvBillType.text = "订单"
                }
                "team_frozen_money","violation","evaluate_deduct_money" -> {
                    b.setSolidColor(Color.parseColor("#66F65E2A"))
                    tvBillType.text = "违约"
                }
                "skill_money","team_refund_deposit","skill_frozen_money" -> {
                    b.setSolidColor(Color.parseColor("#66F65E2A"))
                    tvBillType.text = "保证金"
                }
                "extract" -> {
                    b.setSolidColor(Color.parseColor("#66F65E2A"))
                    tvBillType.text = "提现"
                }
                "pay_product" -> {
                    b.setSolidColor(Color.parseColor("#66F65E2A"))
                    tvBillType.text = "商城"
                }
                "team_service_work_hexiao" -> {
                    b.setSolidColor(Color.parseColor("#66F65E2A"))
                    tvBillType.text = "核销"
                }
            }

            tvBillType.background = b.build()
        }
    }


}
